// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import FastClick from 'fastclick'
import { Checkbox, CheckboxGroup, Row, Col, NavBar, Tabbar, TabbarItem, Tab, Tabs, Field, Cell, CellGroup } from 'vant'
import { TransferDom, Toast, XButton, XHeader, Search } from 'vux'

import vuex from 'vuex'
import App from './App'
import router from './router'
import 'lib-flexible'
import 'vant/lib/vant-css/index.css'
import axios from './utils/axios.js'
import { post, get } from './utils/https.js'
import '@/assets/iconfont/iconfont.css'

Vue.prototype.$axios = axios
Vue.prototype.$post = post
Vue.prototype.$get = get

FastClick.attach(document.body)
//  使用组件
Vue.use(vuex)
var store = new vuex.Store({
  // store对象
  state: {
    isLogin: false,
    toolindex: 1,
    tabView: 'Hot'
  },
  // 获取属性的状态
  getters: {
    // 获取登录状态
    isLogin: state => state.isLogin
  },
  // 设置属性状态
  mutations: {
    // 保存登录状态
    userStatus(state, flag) {
      state.isLogin = flag
    }
  },

  // 应用mutations
  actions: {
    // 获取登录状态
    setUser({ commit }, flag) {
      commit('userStatus', flag)
    }
  }
})

// vant
Vue.use(Checkbox).use(CheckboxGroup)
Vue.use(Tabbar).use(TabbarItem)
Vue.use(Cell).use(CellGroup)
Vue.use(Tab).use(Tabs)
Vue.use(Row).use(Col)
Vue.use(NavBar)
Vue.use(Field)
// vux
Vue.component('x-button', XButton)
Vue.component('x-header', XHeader)
Vue.component('search', Search)
Vue.component('toast', Toast)
Vue.directive('transfer-dom', TransferDom)
Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store, // vuex
  components: { App },
  template: '<App/>'
})
